package com.oraclefmw.crusher.core;

import java.util.Properties;
import java.util.concurrent.BlockingQueue;

import com.oraclefmw.crusher.core.Fragment;
import com.oraclefmw.crusher.core.Worker;

public abstract class AbstractWorker implements Worker {

	BlockingQueue<Fragment> queue;
	Properties props;
	int pageSize;
	
	public AbstractWorker(BlockingQueue<Fragment> queue, Properties props) {

		this.queue = queue;
		this.props = props;
	}

	public void check() {

		String workerType = props.getProperty("worker_type");

		if (workerType == null)
			throw new IllegalArgumentException("please set key 'worker_type'");


		if (props.getProperty("page_size") == null) {
			pageSize = 1;
		} else {
			pageSize = Integer
					.parseInt((String) props.getProperty("page_size"));
		}
	}
}
